
#include "pointer.h"

namespace datashuttle{

SharedObjExpcetion::SharedObjExpcetion(const std::string& what_arg)
	:mWhat(what_arg)
{
}

NullSharedObjException::NullSharedObjException(const std::string& what_arg)
:SharedObjExpcetion(what_arg)
{
}

SharedObject::SharedObject( )
 : _noDelete(false)
{
}

SharedObject::SharedObject(const SharedObject&)
 :_noDelete(false)
{
}

SharedObject::~SharedObject()
{
}

bool SharedObject::operator == ( const SharedObject& b)
{
	return (this == &b);
}
	
void SharedObject::__incRef( )
{
	_ref.inc();
}

void SharedObject::__decRef( )
{
	if( _ref.decThenIfZero() && !_noDelete)
	{
		_noDelete = true;
		delete this;
	}
}
	
int SharedObject::__getRef()
{
	 return _ref.add(0);
}
	
void SharedObject::__setNoDelete(bool noDel)
{
	_noDelete = noDel;
}
	

}//namespace datashuttle

